package com.ucombuy.sponsor.controller;

import com.alibaba.fastjson.JSON;
import com.ucombuy.sponsor.service.IUserService;;
import com.ucombuy.sponsor.vo.CreateUserRequest;
import com.ucombuy.sponsor.vo.CreateUserResponse;
import com.uocmbuy.adver.common.exception.AdverException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by yaosheng on 2021/3/29.
 */
@Slf4j
@RestController
public class UserController {

    private final IUserService userService;

    @Autowired
    public UserController(IUserService userService) {
        this.userService = userService;
    }

    @PostMapping("/create/user")
    public CreateUserResponse createUser(@RequestBody CreateUserRequest request) throws AdverException {

        log.info("ad-sponsor: createUser -> {}", JSON.toJSONString (request));
        return userService.createUser(request);
    }

}
